﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using WindowsLive.Writer.Api;

namespace InsertObject
{
    public partial class ContentEditor : SmartContentEditor
    {
        PluginSettings m_settings;
        ISmartContent m_content;

        public ContentEditor()
        {
            InitializeComponent();
            this.SelectedContentChanged += new EventHandler(ContentEditor_SelectedContentChanged);
        }

        void ContentEditor_SelectedContentChanged(object sender, EventArgs e)
        {
            m_content = SelectedContent;
            m_settings = new PluginSettings(m_content.Properties);
            LoadSettings();
        }

        private void LoadSettings()
        {
            chbxFTP.Checked = m_settings.UseFTP;
        }

        private void chbxFTP_Click(object sender, EventArgs e)
        {
            m_settings.UseFTP = chbxFTP.Checked;
            OnContentEdited();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            using (frmMain editing = new frmMain(m_settings, true))
            {
                DialogResult result = editing.ShowDialog();
                if (result == DialogResult.OK)
                    OnContentEdited();
                LoadSettings();
            }
        }
    }
}
